using System.Collections.Generic;
using System.Windows.Media;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Crusades_UT.Geometry {
  public static class HelperExtensions {
    public static PathFigureCollection GetFigures(this Path path) {
      PathGeometry geometry = path.Data as PathGeometry;
      Assert.IsNotNull(geometry, "Path.Data was not a Geometry");
      Assert.IsTrue(geometry.Figures.Count>0,"Figures collection was empty");
      return geometry.Figures;
    }

    public static PathSegmentCollection GetSegments(this Path path, int figureIndex){
      PathGeometry geometry = path.Data as PathGeometry;
      Assert.IsNotNull(geometry, "Path.Data was not a Geometry");
      Assert.IsTrue(geometry.Figures.Count>figureIndex,"Figures collection contains less than " + figureIndex + " items.");
      
      PathSegmentCollection segments = geometry.Figures[figureIndex].Segments;
      Assert.IsNotNull(segments,"Segments collection is null for Figure " + figureIndex);
      return segments;
    }
  }
}